﻿@model LogOnModel
@{
    Layout = "~/Views/Shared/_LayoutPartial.cshtml";
    ViewBag.ImageUrl = "~/content/images/Unlock.png";
    ViewBag.Title = Html.Global("RES_LOGIN");
}
@{
    var fbAppID = System.Web.Configuration.WebConfigurationManager.AppSettings["facebookAppID"];
    var fbSecret = System.Web.Configuration.WebConfigurationManager.AppSettings["facebookSecret"];
    if (!string.IsNullOrEmpty(fbAppID) && !string.IsNullOrEmpty(fbSecret))
    {
        Facebook.Initialize(fbAppID, fbSecret);
    }
}
@if (Facebook.IsInitialized)
{
    @Facebook.GetInitializationScripts() 
}
@{Ajax.Dna().WidgetZone("Top zone", "zone1").Render();}
<table cellpadding="5px;" cellspacing="5px" style="width: 100%;">
    <tr>
        <td style="width: 450px;">
            @using (Html.BeginForm())
            {
                <table>
                    <tr>
                        <td colspan="3" style="padding: 5px;">
                            <h3>@Html.Global("Login_DNAID")</h3>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3" style="padding: 5px;">
                            @Html.ValidationSummary()
                        </td>
                    </tr>
                    <tr>
                        <td style="white-space: nowrap; font-size: 150%; vertical-align: top;">
                            <label for="UserName">
                                @Html.Global("RES_USER_NAME")</label>
                        </td>
                        <td style="padding: 5px;">
                            @(Ajax.DnaFor().TextBox(m => m.UserName)
                                         .Width(300)
                                       .IconImageUrl(Url.Content("~/content/images/icon_contact_16.gif"))
                                       .GetHtml()
                                 )
                        </td>
                        <td>@Html.ValidationMessageFor(m => m.UserName, "*")
                        </td>
                    </tr>
                    <tr>
                        <td style="white-space: nowrap; font-size: 150%; vertical-align: top;">
                            <label for="Password">
                                @Html.Global("RES_PASSWORD")</label>
                        </td>
                        <td style="padding: 5px;">
                            @(
 Ajax.DnaFor().TextBox(m => m.Password)
                                   .Password()
                                   .Width(300)
                                   .IconImageUrl(Url.Content("~/content/images/icon_key_16.gif"))
                                   .GetHtml()
                            )
                        </td>
                        <td>@Html.ValidationMessageFor(m => m.Password, "*")
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3" style="padding: 5px;">
                            @*@Html.CheckBoxFor(m => m.RememberMe, new { style = "width:16px;" })*@
                            @Html.CheckBox("LogOnModel.RememberMe", true)
                            <label class="inline" for="LogOnModel_RememberMe">
                                @Html.Global("RES_REMEMBER_ME")</label>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" style="padding: 5px;">
                            @{
                Ajax.Dna().Button()
                    .Text(Html.Global("RES_FORGETPWD"))
                    .ImageIcons(Url.Content("~/content/images/icon_help_16.png"))
                    .ChangeType(ButtonTypes.LinkButton)
                    .NavigateUrl(Url.Action("Receive"))
                    .Render();
                            }
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" style="padding: 5px; text-align: center;">
                            @Ajax.Submit(Html.Global("RES_LOGIN"), "ui-icon ui-icon-key")
                        </td>
                    </tr>
                </table>
            }
        </td>
        <td valign="top">
            <form action="@Url.Action("OpenId", "Account", new { Area = "", website = "home" })" id="openIdLoginForm" method="post" onsubmit="_combineUrl();">
            <table>
                <tr>
                    <td colspan="3">
                        <h3>@Html.Global("Login_OpenID")
                        </h3>
                    </td>
                </tr>
                <tr>
                    <td style="border: 1px solid #cccccc; height: 60px; width: 100px; text-align: center;"
                        class="d-openid-icon">
                        <img src="@Url.Content("~/content/images/google.gif")" style="cursor:pointer;" onclick="openID.signIn('google');"  alt="Google" title="Google"/>
                    </td>
                    <td style="border: 1px solid #cccccc; height: 60px; width: 100px; text-align: center;"
                        class="d-openid-icon">
                        <img src="@Url.Content("~/content/images/yahoo.gif")" style="cursor:pointer;"  onclick="openID.signIn('yahoo');"  alt="Yahoo" title="Yahoo"/>
                    </td>
                    <td style="border: 1px solid #cccccc; height: 60px; width: 100px; text-align: center;"
                        class="d-openid-icon">
                        <img src="@Url.Content("~/content/images/aol.gif")" style="cursor:pointer;" onclick="openID.signIn('aol');"  alt="aol" title="AOL"/>
                    </td>
                </tr>
                <tr>
                    <td colspan="3">
                        <table cellpadding="5">
                            <tr>
                                <td style="border: 1px solid #cccccc;" class="d-openid-icon">
                                    <img src="@Url.Content("~/content/images/openid.png")" style="width:16px;height:16px;cursor:pointer;" onclick="openID.signIn('openid');"  alt="openid" title="OpenID"/>
                                </td>
                                <td style="border: 1px solid #cccccc;">
                                    <img src="@Url.Content("~/content/images/myopenid_sm.gif")" style="width:16px;height:16px;cursor:pointer;"  onclick="openID.signIn('myopenid');"  alt="myopenid" title="MyOpen ID"/>
                                </td>
                                <td style="border: 1px solid #cccccc;" class="d-openid-icon">
                                    <img src="@Url.Content("~/content/images/blogger_sm.gif")"  style="width:16px;height:16px;cursor:pointer;" onclick="openID.signIn('blogger');"  alt="Blogger" title="Blogger"/>
                                </td>
                                <td style="border: 1px solid #cccccc;" class="d-openid-icon">
                                    <img src="@Url.Content("~/content/images/flickr_sm.gif")"  style="width:16px;height:16px;cursor:pointer;"  onclick="openID.signIn('flickr');"  alt="Flickr" title="Flickr"/>
                                </td>
                                <td style="border: 1px solid #cccccc;" class="d-openid-icon">
                                    <img src="@Url.Content("~/content/images/livejournal_sm.gif")"  style="width:16px;height:16px;cursor:pointer;"  onclick="openID.signIn('livejournal');"  alt="Livejournal" title="Live Journal"/>
                                </td>
                                <td style="border: 1px solid #cccccc;" class="d-openid-icon">
                                    <img src="@Url.Content("~/content/images/wordpress_sm.gif")"  style="width:16px;height:16px;cursor:pointer;"  onclick="openID.signIn('wordpress');"  alt="wordpress" title="Wordpress"/>
                                </td>
                                <td style="border: 1px solid #cccccc;" class="d-openid-icon">
                                    <img src="@Url.Content("~/content/images/myspace_s.gif")"  style="width:16px;height:16px;cursor:pointer;"  onclick="openID.signIn('myspace');"  alt="myspace" title="MySpace"/>
                                </td>
                                @*                                <td style="border: 1px solid #cccccc;" class="d-openid-icon">
                                    <img src="@Url.Content("/content/images/icon_twitter_16.png")" style="width:16px;height:16px;cursor:pointer;" onclick="location='@Url.Action("TwitterOAuth", "Account")';" alt="Twitter" />
                                </td>*@
                            </tr>
                        </table>
                    </td>
                </tr>
                @if (Facebook.IsInitialized)
                {
                    <tr>
                        <td colspan="3" style="text-align: center; border-top: solid 1px #cccccc; padding: 10px;">
                            <fb:login-button autologoutlink="true" size="large" length="long" onlogin="_onfbLogin()"
                                show-faces="false" perms="">
                         </fb:login-button>
                            <script type="text/javascript">
                             function _onfbLogin() {
                                 FB.api("/me", function (user) {
                                     if (user.id){
                                      $.post("@Url.Action("FBConnect", "Account", new { Area = "" })",user,function(redirect){
                                        location=redirect;
                                      });
                                      }
                                 });
                             }
                            </script>
                        </td>
                    </tr>
                }
                <tr>
                    <td colspan="3" style="text-align: center; height: 60px; vertical-align: middle;
                        display: none;" id="opendIDFields">
                        <div id="id_summary">
                        </div>
                        @Ajax.Dna().TextBox("OpenIDAccount").GetHtml()
                        <input id="openIdUrl" name="openIdUrl" type="hidden" />
                    </td>
                </tr>
                <tr>
                    <td colspan="3" style="padding: 5px; text-align: center;">
                        @Ajax.Submit(Html.Global("RES_LOGIN"), "ui-icon ui-icon-key")
                    </td>
                </tr>
            </table>
            </form>
            @{Ajax.Dna().WidgetZone("Right zone", "zone2").Render();}
        </td>
    </tr>
</table>
<script type="text/javascript">
    function _combineUrl() {
        var _url = $("#openIdUrl").val(),
        _account = $("#OpenIDAccount").val(),
        _openIDURL = "";
        if ((_account == "") && (_url == "")) return false;

        if (_account) {
            if (_url == "") _openIDURL = _account;
            if ((_url) && (_account)) _openIDURL = _url.replace("{0}", _account);
            $("#openIdUrl").val(_openIDURL);
        }
    }

    window.openID = {
        signIn: function (_site) {
            $("#OpenIDAccount").val("");
            $("#openIdUrl").val("");

            if (_site == "openid") {
                $("#OpenIDAccount").val("http://");
                $("#id_summary").text("@Html.Global("OpenID_EnterYourOpenID")");
            }
            

            if (_site == "myopenid") {
                $("#openIdUrl").val("http://{0}.myopenid.com");
                $("#id_summary").text("@Html.Global("OpenID_EnterYourMyOpenID")");
            }

            if (_site == "blogger") {
                $("#id_summary").text("@Html.Global("OpenID_EnterYourBlogger")");
                $("#openIdUrl").val("http://{0}.blogspot.com");
            }

            if (_site == "google") {
                $("#opendIDFields").hide();
                $("#openIdUrl").val("https://www.google.com/accounts/o8/id");
                $("#openIdLoginForm").submit();
                return;
            }

            if (_site == "yahoo") {
                $("#opendIDFields").hide();
                $("#openIdUrl").val("http://yahoo.com/");
                $("#openIdLoginForm").submit();
                return;
            }

            if (_site == "aol") {
                $("#openIdUrl").val("http://openid.aol.com/{0}");
                $("#id_summary").text("@Html.Global("OpenID_EnterAOL")");
            }

            if (_site == "flickr") {
                $("#openIdUrl").val("http: //www.flickr.com/photos/{0}");
                $("#id_summary").text("@Html.Global("OpenID_EnterFlickrUserName")");
            }

            if (_site == "wordpress") {
                $("#openIdUrl").val("http://{0}.wordpress.com");
                $("#id_summary").text("@Html.Global("OpenID_EnterWordPressName")");
            }

            if (_site == "myspace") {
                $("#openIdUrl").val("http://www.myspace.com/{0}");
                $("#id_summary").text("@Html.Global("OpenID_EnterMySpaceName")");
            }

            if (_site == "livejournal") {
                $("#openIdUrl").val("http://{0}.livejournal.com");
                $("#id_summary").text("@Html.Global("OpenID_EnterJournalName")");
            }

            $("#opendIDFields").show();
            $("#OpenIDAccount").focus();
        }
    }
</script>
@{Ajax.Dna().WidgetZone("Bottom zone", "zone3").Render();}
